home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Generic Fax2&ARA < prev    next >
Text File  |  1993-12-12  |  6KB  |  270 lines

  1. ! Version 2.1
  2. !
  3. !$ Requires: Class 2 fax modem, hardware handshaking cable.
  4.  
  5. !$ Supports: fax and ARA software in the server mode.
  6.  
  7. !$ Use:   Class 2 for Fax, ARA/LineShare for ARA.
  8.  
  9. !$ Read:  your modem manual to modify the "AT" strings.
  10.  
  11. !$ See:   the Generic Scripts Guide for details.
  12.  
  13.  
  14. ^2 Speaker On:          = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  15. ^3 Speaker Volume:         = Enum("Low"="1","Medium"="2","High"="3") "2"
  16. ^4 Answer On:           = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  17. ^5 Fax Identifier:      = Text "Stalker_GmbH"
  18. ^6 AT for Normal mode:  = Text ""
  19. ^7 AT for HW Handshake: = Text ""
  20. ^8 AT for SW Handshake: = Text ""
  21. ! ------------------------------------------
  22. ! Resetting the modem:
  23. ! ------------------------------------------
  24. @Hangup
  25.   SetTries 2
  26.   Flush
  27.   HsReset 0,0,17,19,0,0
  28. !
  29. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  30. ! to enter the command mode
  31. !
  32. @Label 1
  33.   matchclr
  34.   matchstr 1 2 "OK\r\n"
  35.   write "ATH0&F\r"
  36.   matchread 20
  37.   Write "+++"
  38.   DtrClear
  39.   LBreak
  40.   DtrSet
  41. !
  42.   DecTries
  43.   IfTries 0 1
  44. !
  45. ! OSErr -6019 "Modem error - the modem is not responding"
  46. !
  47.   exit -6019
  48. @Label 2
  49.   write "AT+FCLASS=0\r"
  50.   Jsr 100
  51.   write "AT+FAA=0\r"
  52.   Jsr 100
  53.   exit 0
  54.  
  55. ! ------------------------------------------
  56. !    Receiving incoming calls
  57. ! ------------------------------------------
  58. @ANSWER
  59.   SetVar A ""
  60.   IfStr A 50 "^6^7^8"
  61. @Label 10
  62. !
  63. ! Set the modem preferred speed first
  64. !
  65.   SerReset 19200,0,8,1
  66.   Jsr 80
  67. !
  68. ! Set the common options
  69.   Jsr 70
  70. !
  71. ! Set the communication options:
  72. ! • Normal connection (for ARA), report DCE speed
  73. ! • HW flow control   (for ARA, Fax should not use a handshake on receiving)
  74.   Write "AT^7^6\r"
  75.   Jsr 100
  76. !
  77. ! Set Fax parameters: LID, DCC,BOR
  78. !
  79.   Write "AT+FCLASS=2\r"
  80.   Jsr 100
  81.   Write "AT+FLID=\"^5\"\r"
  82.   Jsr 100
  83.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  84.   Jsr 100
  85.   Write "AT+FBOR=1\r"
  86.   Jsr 100
  87.   Write "AT+FCR=1\r"
  88.   Jsr 100
  89. !
  90. ! Tell the modem to determine the type of the incoming call
  91. ! Fetch the tube after ^4 rings
  92. !
  93.   Write "ATS0=^4+FAA=1\r"
  94.   Jsr 100
  95. !
  96. ! Everything is ready - let's sit and wait for a call
  97. ! We'll wait for 2 minutes, then reinitiate the modem
  98. !
  99.   Note "Waiting for a fax or ARA call…"
  100. @Label 15
  101.   MatchClr
  102.   matchstr 1 16 "RING\r\n"
  103.   matchstr 2 20 "\r\nCARRIER "
  104.   matchstr 3 20 "\r\nCONNECT "
  105.   matchstr 5 30 "\r\n+FCON"
  106.   matchstr 6 10 "\r\nNO "
  107.   matchstr 7 10 "\r\nBUSY"
  108.   Matchread 1200
  109.   jump 10
  110. @Label 16
  111.   Note "Ring…"
  112.   jump 15
  113. !
  114. ! Data connection has been established (we read "CARRIER" or "CONNECT ")
  115. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  116. ! if it was an incoming call, put the "RING" before the "CONNECT"
  117. !
  118. @Label 20
  119.   QueueInput "\r\nCARRIER "
  120.   ifOriginate 21
  121.   QueueInput "\r\nRING\r\n"
  122. @Label 21
  123.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  124. !
  125. ! Fax connection has been established (we read "+FCON")
  126. ! Put the +FCON back to the buffer,
  127. ! if it was an incoming call, put the "RING" before the "+FCON"
  128. ! Attach the "Fax" subPort
  129. !
  130. @Label 30
  131.   QueueInput "\r\n+FCON"
  132.   ifOriginate 31
  133.   QueueInput "\r\nRING\r\n"
  134. @Label 31
  135.   Attach "Fax" (DTR,Reset,Escape,IdleLimit=30)
  136.  
  137. @Label 50
  138.   Note "Suspended"
  139.   Say "Press the Options… button to enter the AT-strings for your modem!"
  140.   Pause 1200
  141.   Jump 50
  142. ! ------------------------------------------
  143. ! Originating a call through the "ARA" subport
  144. ! ------------------------------------------
  145. @ORIGINATE "ARA"
  146.   SerReset 19200,0,8,1
  147.   Jsr 80
  148. !
  149. ! Set the common options
  150. !
  151.   Jsr 70
  152. !
  153. ! Set the Data mode:
  154. ! • Normal connection (no compression, correction - for ARA), report DCE rate
  155. ! • HW Handshake
  156. ! • S7:  time-out (90 sec) for long-distance call (if you use them)
  157. !
  158.   Write "AT^7^6S7=90\r"
  159.   Jsr 100
  160. !
  161. ! Prepare to receive all error result codes, dial the number
  162. !
  163.   Jsr 90
  164.   MatchStr 1 20 "\r\nCARRIER "
  165.   MatchStr 2 20 "\r\nCONNECT "
  166.   MatchRead 1000
  167.   Write "\r"
  168.   Exit -6019
  169.  
  170. ! ------------------------------------------
  171. ! Originating a call through the "Fax" subPort
  172. ! ------------------------------------------
  173. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  174. !
  175. ! Set the "Fax" speed
  176. !
  177.   SerReset 19200,0,8,1
  178.   Jsr 80
  179. !
  180. ! Set the common options
  181. !
  182.   Jsr 70
  183. !
  184. ! Set the Fax mode
  185. ! • Xon/Xoff handshake
  186. ! • DSR always on
  187. !
  188.   Write "AT&S0^8+FCLASS=2\r"
  189.   Jsr 100
  190. !
  191. ! Now emit all commands that the application has sent to that port,
  192. !
  193.   Jsr 60
  194. !
  195. ! Prepare to receive all error result codes, dial the number
  196. !
  197.   Jsr 90
  198.   MatchStr 1 30 "\r\n+FCON"
  199.   MatchRead 1000
  200.   Write "\r"
  201.   Exit -6019
  202. !
  203. ! This section emits all modem commands sent from the client application
  204. ! For each set of commands the "OK" answer is awaited
  205. !
  206. @Label 60
  207.   EmitStart
  208. @Label 61
  209.   EmitCommand 62
  210.   Jsr 100
  211.   Jump 61
  212. @Label 62
  213.   return
  214. !
  215. ! This section initiates the modem before ANSWER and ORIGINATEs:
  216. ! extended responses + speaker control +
  217. ! command mode on Dtr drop + DCD valid
  218. ! Verbal responses mode, no echo 
  219. !
  220. @Label 70
  221.   Write "ATX4M^2L^3&D2&C1V1E0\r"
  222.   Jsr 100
  223.   return 
  224.  
  225. !
  226. ! This section syncronize the modem after the serial port speed switching
  227. !
  228. @Label 80
  229.   ChrDelay 1
  230.   Write "AT\r"
  231.   ChrDelay 0
  232.   Jsr 100
  233.   return
  234. !
  235. ! Prepare to receive error result codes, send the dialing command and
  236. ! set the user's handshake mode
  237. !
  238. @Label 90
  239.   MatchClr
  240.   MatchStr 2 91 "NO DIALTONE\r\n"
  241.   MatchStr 3 92 "BUSY\r\n"
  242.   MatchStr 4 93 "NO CARRIER\r\n"
  243.   MatchStr 5 94 "NO ANSWER\r\n"
  244.   Write "ATD^1\r"
  245.   HsReset *
  246.   return
  247. @Label 91
  248.   exit -6020
  249. @Label 92
  250.   exit -6022
  251. @Label 93
  252.   exit -6021
  253. @Label 94
  254.   exit -6023
  255. !
  256. ! Processing the AT command:
  257. ! OK -> proceed
  258. ! ERROR or TimeOut ->exit -6019
  259. ! It can be called AFTER the "Write" command, since LineShare buffers input
  260. !
  261. @Label 100
  262.   MatchClr
  263.   MatchStr 1 102 "\r\nOK\r\n"
  264.   MatchStr 2 101 "\r\nERROR\r\n"
  265.   MatchRead 20
  266. @Label 101
  267.   Exit -6019
  268. @Label 102
  269.   return
  270.